{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Cantilever beam with a traction load on one side"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![cant.png](figures/cant.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "using JuAFEM\n",
    "using Tensors\n",
    "using TimerOutputs\n",
    "using UnicodePlots\n",
    "const to = TimerOutput();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "hex = false\n",
    "geoshape = hex ? Hexahedron : Tetrahedron\n",
    "refshape = hex ? RefCube    : RefTetrahedron\n",
    "order = hex? 2 : 1;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "const dim = 3\n",
    "corner1 = Vec{dim}((0.0, 0.0, 0.0))\n",
    "corner2 = Vec{dim}((10.0, 1.0, 1.0))\n",
    "grid = generate_grid(geoshape, (60, 6, 6), corner1, corner2);\n",
    "# Extract the left boundary\n",
    "addnodeset!(grid, \"clamped\", x -> norm(x[1]) ≈ 0.0);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Interpolations and values\n",
    "interpolation_space = Lagrange{dim, refshape, 1}()\n",
    "quadrature_rule = QuadratureRule{dim, refshape}(order)\n",
    "cellvalues = CellVectorValues(quadrature_rule, interpolation_space);\n",
    "facevalues = FaceVectorValues(QuadratureRule{dim-1, refshape}(order), interpolation_space);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DofHandler\n",
       "  Fields:\n",
       "    u dim: 3\n",
       "  Total dofs: 8967\n",
       "  Dofs per cell: 12"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# DofHandler\n",
    "dh = DofHandler(grid)\n",
    "push!(dh, :u, dim) # Add a displacement field\n",
    "close!(dh)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  0.043103 seconds (31 allocations: 35.502 MiB, 29.53% gc time)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\u001b[37m                     Sparsity Pattern\n",
       "\u001b[39m\u001b[37m        ┌──────────────────────────────────────────┐\u001b[39m    \n",
       "      \u001b[37m1\u001b[39m\u001b[37m │\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[31m> 0\u001b[39m\n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[34m< 0\u001b[39m\n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "   \u001b[37m\u001b[39m    \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢿\u001b[39m\u001b[31m⣷\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "       \u001b[37m\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[31m⣄\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "   \u001b[37m8967\u001b[39m\u001b[37m │\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[37m⠀\u001b[39m\u001b[31m⠙\u001b[39m\u001b[31m⢷\u001b[39m\u001b[37m│\u001b[39m \u001b[37m\u001b[39m   \n",
       "\u001b[37m        └──────────────────────────────────────────┘\u001b[39m    \n",
       "\u001b[37m        1\u001b[39m\u001b[37m                    \u001b[39m\u001b[37m                   8967\n",
       "\u001b[39m\u001b[37m                        nz = 207150\n",
       "\u001b[39m"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "@time K = create_symmetric_sparsity_pattern(dh); # assemble only upper half since it is symmetric\n",
    "fill!(K.data.nzval, 1.0);\n",
    "spy(K.data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Boundaryconditions\n",
    "dbc = DirichletBoundaryConditions(dh)\n",
    "# Add a homogenoush boundary condition on the \"clamped\" edge\n",
    "add!(dbc, :u, getnodeset(grid, \"clamped\"), (x,t) -> [0.0, 0.0, 0.0], collect(1:dim))\n",
    "close!(dbc)\n",
    "t = 0.0\n",
    "update!(dbc, t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create the stiffness tensor\n",
    "E = 200e9\n",
    "ν = 0.3\n",
    "λ = E*ν / ((1+ν) * (1 - 2ν))\n",
    "μ = E / (2(1+ν))\n",
    "δ(i,j) = i == j ? 1.0 : 0.0\n",
    "g(i,j,k,l) = λ*δ(i,j)*δ(k,l) + μ*(δ(i,k)*δ(j,l) + δ(i,l)*δ(j,k))\n",
    "C = SymmetricTensor{4, dim}(g);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "function doassemble{dim}(cellvalues::CellVectorValues{dim}, facevalues::FaceVectorValues{dim}, \n",
    "                         K::Symmetric, grid::Grid, dh::DofHandler, C::SymmetricTensor{4, dim})\n",
    "\n",
    "    \n",
    "    f = zeros(ndofs(dh))\n",
    "    assembler = start_assemble(K, f)\n",
    "    \n",
    "    n_basefuncs = getnbasefunctions(cellvalues)\n",
    "\n",
    "    fe = zeros(n_basefuncs) # Local force vector\n",
    "    Ke = Symmetric(zeros(n_basefuncs, n_basefuncs), :U) # Local stiffness mastrix\n",
    "    \n",
    "    t = Vec{3}((0.0, 1e8, 0.0)) # Traction vector\n",
    "    b = Vec{3}((0.0, 0.0, 0.0)) # Body force\n",
    "    ɛ = [zero(SymmetricTensor{2, dim}) for i in 1:n_basefuncs]\n",
    "    @inbounds for (cellcount, cell) in enumerate(CellIterator(dh))\n",
    "        @timeit to \"assem\" begin\n",
    "        fill!(Ke.data, 0)\n",
    "        fill!(fe, 0)\n",
    "        \n",
    "        reinit!(cellvalues, cell)\n",
    "        for q_point in 1:getnquadpoints(cellvalues)\n",
    "            for i in 1:n_basefuncs\n",
    "                ɛ[i] = symmetric(shape_gradient(cellvalues, q_point, i)) \n",
    "            end\n",
    "            dΩ = getdetJdV(cellvalues, q_point)\n",
    "            for i in 1:n_basefuncs\n",
    "                δu = shape_value(cellvalues, q_point, i)\n",
    "                fe[i] += (δu ⋅ b) * dΩ\n",
    "                ɛC = ɛ[i] ⊡ C\n",
    "                for j in i:n_basefuncs # assemble only upper half\n",
    "                    Ke.data[i, j] += (ɛC ⊡ ɛ[j]) * dΩ # can only assign to parent of the Symmetric wrapper\n",
    "                end\n",
    "            end\n",
    "        end\n",
    "        \n",
    "        for face in 1:nfaces(cell)\n",
    "            if onboundary(cell, face) && (cellcount, face) ∈ getfaceset(grid, \"right\")\n",
    "                reinit!(facevalues, cell, face)\n",
    "                for q_point in 1:getnquadpoints(facevalues)\n",
    "                    dΓ = getdetJdV(facevalues, q_point)\n",
    "                    for i in 1:n_basefuncs\n",
    "                        δu = shape_value(facevalues, q_point, i)\n",
    "                        fe[i] += (δu ⋅ t) * dΓ\n",
    "                    end\n",
    "                end\n",
    "            end\n",
    "        end\n",
    "        global_dofs = celldofs(cell)\n",
    "        assemble!(assembler, global_dofs, fe, Ke)\n",
    "        end # timer\n",
    "    end\n",
    "    return K, f\n",
    "end;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " \u001b[1m------------------------------------------------------------------\u001b[22m\n",
      "                           Time                   Allocations      \n",
      "                   ----------------------   -----------------------\n",
      " Tot / % measured:     14.7ms / 88.0%            417KiB / 0.05%    \n",
      "\n",
      " Section   ncalls     time   %tot     avg     alloc   %tot      avg\n",
      " ------------------------------------------------------------------\n",
      " assem      10.8k   12.9ms   100%  1.20μs      224B  100%        0B\n",
      " \u001b[1m------------------------------------------------------------------\u001b[22m"
     ]
    }
   ],
   "source": [
    "reset_timer!(to)\n",
    "K, f = doassemble(cellvalues, facevalues, K, grid, dh, C);\n",
    "print_timer(to; linechars = :ascii)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  0.001642 seconds (62 allocations: 17.453 KiB)\n"
     ]
    }
   ],
   "source": [
    "# Modify K and f such that K \\ f gives correct boundary conditions\n",
    "@time apply!(K, f, dbc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  0.097025 seconds (9.32 k allocations: 37.100 MiB, 2.46% gc time)\n"
     ]
    }
   ],
   "source": [
    "@time u = cholfact(K) \\ f;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1-element Array{String,1}:\n",
       " \"cantilever.vtu\""
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Save file\n",
    "vtkfile = vtk_grid(\"cantilever\", dh)\n",
    "vtkfile = vtk_point_data(vtkfile, dh, u)\n",
    "vtk_save(vtkfile)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cantilever successful\n"
     ]
    }
   ],
   "source": [
    "Base.Test.@test maximum(u)  ≈ 1.919600482922295\n",
    "println(\"Cantilever successful\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "name": "julia-0.6",
   "display_name": "Julia 0.6.0",
   "language": "julia"
  },
  "language_info": {
   "mimetype": "application/julia",
   "file_extension": ".jl",
   "version": "0.6.0",
   "name": "julia"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
